package fr.km.client.ui;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.InlineLabel;

public class SearchOverviewDisplay extends Composite {
	private InlineLabel pageNumberLabel;
	private InlineLabel totalResultsLabel;
	private FlowPanel panel;
	
	private InlineLabel l1;//Résultats 
	private InlineLabel l2;//sur un total de 
	private InlineLabel l3;//articles trouvés
	
	public SearchOverviewDisplay() {
		ensureDebugId("searchOverview");
		
		panel = new FlowPanel();
		
		initWidget(panel);
		
		panel.setStyleName("search-overview");
	}
	
	public void setDetails(int pageNumber, int totalPages, int totalResults) {
		panel.clear();
		buildOverview();
		pageNumberLabel.setText(""+pageNumber+"-"+totalPages);
		totalResultsLabel.setText(""+totalResults);
	}
	
	private void buildOverview() {
		if(l1 == null) {
			l1 = new InlineLabel("Résultats ");
			l2 = new InlineLabel(" sur un total de ");
			l3 = new InlineLabel(" articles trouvés.");
			pageNumberLabel = new InlineLabel();
			totalResultsLabel = new InlineLabel();
		}
		
		panel.add(l1);
		panel.add(pageNumberLabel);
		panel.add(l2);
		panel.add(totalResultsLabel);
		panel.add(l3);
	}
}
